/**
 * 
 */
package com.zznode.client.wlanpolling.test;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ExpandableListView;

import com.zznode.client.wlanpolling.R;

/**
 * 
 *
 */
public class PollTestActivity extends Activity {

	public PollTestAdaptor pollTestAdaptor;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.pollingtest);
		ExpandableListView listView = (ExpandableListView) findViewById(R.id.pollingtest);

		pollTestAdaptor = new PollTestAdaptor(this);
		listView.setAdapter(pollTestAdaptor);
		listView.setGroupIndicator(null);
		listView.setClickable(true);

		for (int i = 0; i < pollTestAdaptor.getGroupCount(); i++) {
			listView.expandGroup(i);
		}

		listView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {

			@Override
			public boolean onChildClick(ExpandableListView parent, View v,
					int groupPosition, int childPosition, long id) {
				GroupItem groupItem = (GroupItem) pollTestAdaptor
						.getGroup(groupPosition);
				if (groupItem == null)
					return false;
				ChildItem childItem = groupItem.getChildrenItem().get(
						childPosition);
				if (childItem == null)
					return false;

				Intent intent = null;
				switch (childItem.getTag()) {
				case PollTestAdaptor.TEST_AUTO_ALL:
					intent = new Intent(PollTestActivity.this,
							PollAutoTestActivity.class);
					startActivity(intent);
					break;
				case PollTestAdaptor.TEST_MANUAL_APREL:
					intent =  new Intent(PollTestActivity.this, ReassociateTestActivity.class);
					startActivity(intent);
					break;
				case PollTestAdaptor.TEST_MANUAL_APSWITCH:
					intent = new Intent(PollTestActivity.this, APSwitchTestActivity.class);
					startActivity(intent);
					break;
				case PollTestAdaptor.TEST_MANUAL_COVERAGE:
					 intent = new Intent(PollTestActivity.this, CoverTestActivity.class);
					 startActivity(intent);
					break;
				case PollTestAdaptor.TEST_MANUAL_FTPDOWNLOAD:
					intent = new Intent(PollTestActivity.this, FTPDownloadActivity.class);
					startActivity(intent);
					break;
				case PollTestAdaptor.TEST_MANUAL_FTPUPLOAD:
					intent = new Intent(PollTestActivity.this, FTPUploadActivity.class);
					startActivity(intent);
					break;
				case PollTestAdaptor.TEST_MANUAL_PING:
					intent = new Intent(PollTestActivity.this, ManualPingActivity.class);
					startActivity(intent);
					break;
				case PollTestAdaptor.TEST_MANUAL_WEBAUTH:
					//TODO
					break;
				default:
					break;
				}
				return false;
			}
		});
	}
}
